package xyz.zdsoft.project_group_manage_module.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.zdsoft.common.utils.Result;
import xyz.zdsoft.project_group_manage_module.service.UpdateTeamGchService;

import javax.annotation.Resource;
import java.util.HashMap;

@RestController
@Api(tags = "项目组管理")
public class AdminUpdateTeamController {
    @Resource
    private UpdateTeamGchService updateTeamGchService;
    @ApiImplicitParams({
            @ApiImplicitParam(name = "teamId",value = "项目组id",example = "1",required = true),
            @ApiImplicitParam(name = "teamName",value = "项目组名称",example = "新JAVA小组",required = true),
            @ApiImplicitParam(name = "isGraduation",value = "是否结业(0结业，1未结业)",required = true)
    })
    @ApiOperation("编辑项目组")
    @PostMapping("/UpdateTeam")
    public Result updateTeam(Long teamId,String teamName,String isGraduation){
        HashMap<String,Object> map=new HashMap<>();
        map.put("teamId",teamId);
        map.put("teamName",teamName);
        map.put("isGraduation",isGraduation);

        if (updateTeamGchService.selTeamHave(map)>0){
            return Result.error().message("该项目组名称已存在");
        }
        else if (updateTeamGchService.updateTeam(map)>0){
            return Result.ok().message("更新成功");
        }
        else return Result.error().message("更新失败或者说您没做任何修改");

    }
}
